{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!-- （勿改动，执行即可）执行更改背景 -->\n",
       "<link rel=\"stylesheet\" href=\"exam.css\" type=\"text/css\">\n",
       "<h1 style=\"color: red;\">注意单元格的第一行不能改动，否则会影响自动打分</h1>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "<!-- （勿改动，执行即可）执行更改背景 -->\n",
    "<link rel=\"stylesheet\" href=\"exam.css\" type=\"text/css\">\n",
    "<h1 style=\"color: red;\">注意单元格的第一行不能改动，否则会影响自动打分</h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 始000（勿改动，执行即可）win系统\n",
    "e = %env\n",
    "_which_= \"C\"  # 卷号\n",
    "import PandasCourse as PC\n",
    "from IPython.display import Markdown\n",
    "Markdown(PC.msgs['opening'].format(w=_which_, d=e['HOMEDRIVE']+ e['HOMEPATH']))    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "# Python 期中考（C卷）：目前工作目录\n",
       "* 共6题，每题20分，80分及格，最高分120，作题时间60分钟。\n",
       "*  答题格首行如 ***# 003*** 勿删除或改动 \n",
       "* 可先挑难度较易的题先做，🌶个数越高越难\n",
       "* 执行一格格，最后一格可回报分数（仅供参考）\n",
       " ##提交此.ipynb档，必检查： \n",
       "   * 档名✍C_学号✍（只能用半角数字9码）\n",
       "   *  下格 输入学号（半角数字9码） \n",
       "\n",
       "\n",
       "# 🛂输入学号🛂"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 始000（勿改动，执行即可）mac系统\n",
    "e = %env\n",
    "_which_= \"C\"  # 卷号\n",
    "import PandasCourse as PC\n",
    "from IPython.display import Markdown\n",
    "Markdown(PC.msgs['opening'].format(w=_which_, d=\"\"))    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  🙊🙈🙉 Python 🙉🙈🙊"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 始001（✍请改动並执行）\n",
    "student_id = \"\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 本试题参考数据信息及提示信息：    \n",
    "> 1. df_C1:  作者地址(Author Address)         \n",
    "> 2. text:  所有作者地址文本     \n",
    "> 3. info:所有作者地址列表\n",
    "> 4. Q5-Q6为独立题目，可以尝试先做\n",
    "> 5. Q4比较难"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 002 数据准备\n",
    "# 学生直接执行\n",
    "import pandas as pd\n",
    "df = pd.read_csv(\"WOS.csv\",index_col=[0])\n",
    "df_C1 = df[['PY','C1']]\n",
    "text = ''.join(df_C1.fillna(\"0\")['C1'].tolist())\n",
    "text\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q1（20分） 🌶 易\n",
    "* 查找\"USA\"的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# A-1\n",
    "phrase = #✍\n",
    "freq_table_phrase = #✍\n",
    "freq_table_phrase"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q2 （20分） 🌶 易\n",
    "* 用英文\";&nbsp;\\[\"拆分,生成list_split列表，每一个句子是一个独立的列表元素 \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "list_split = #✍\n",
    "list_split"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q3 20分 易\n",
    "* 筛选作者所有地址列表info中出现USA的内容，组成新的列表(20分)\n",
    "* 答案示例：\n",
    "```\n",
    "USA_list: \n",
    "['[Freeman, Scott; Eddy, Sarah L.; McDonough, Miles; Okoroafor, Nnadozie; Jordt, Hannah; Wenderoth, Mary Pat] Univ Washington, Dept Biol, Seattle, WA 98195 USA; [Smith, Michelle K.] Univ Maine, Sch Biol & Ecol, Orono, ME 04469 USA',\n",
    " '[Henderson, Charles] Western Michigan Univ, Dept Phys, Kalamazoo, MI 49008 USA; [Henderson, Charles] Western Michigan Univ, Mallinson Inst Sci Educ, Kalamazoo, MI 49008 USA; [Finkelstein, Noah] Univ Colorado, Dept Phys, Boulder, CO 80309 USA',...\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# C-1 学生直接执行\n",
    "info= df['C1'].fillna(\"空缺值\").tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# C-2\n",
    "STEM_list = []\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "STEM_list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 👽👼🤶  你可以的  🤶👼👽\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Q4 （20分）🌶🌶 🌶 难\n",
    "* 尝试用python代码取出 邮政编码（注：5位的数字信息）并存进邮编列表中。\n",
    "* 答案示例：\n",
    "```\n",
    "['98195',\n",
    " '04469',\n",
    " '49008',\n",
    " '49008',\n",
    " '80309',\n",
    " ...\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# D-1\n",
    "邮编_list = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# D-2\n",
    "for i in info:\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "邮编_list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q5 20分 🌶🌶\n",
    "* 尝试将年份列表中的不是 空缺值的值转换成整数保存在PY_list_int列表中\n",
    "* 答案示例：\n",
    "```\n",
    "[2014,\n",
    " 2011,\n",
    " 2016,\n",
    " 2013,\n",
    " 2009,\n",
    " ...]\n",
    " ```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# E-1 数据准备 学生直接执行\n",
    "PY_list = df_C1['PY'].fillna(\"空缺值\").to_list()\n",
    "PY_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "PY_list_int = []\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "PY_list_int"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Q6 20分 🌶🌶 \n",
    "\n",
    "* 根据Q5计算每个年份的数量并将年份作为key，数量作为value创建字典\n",
    "* 答案示例：\n",
    "```\n",
    "{2014: 58,\n",
    " 2011: 17,\n",
    " 2016: 138,\n",
    " 2013: 42,\n",
    " 2009: 10,\n",
    " ...}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "PY_count = {}\n",
    "#✍✍✍\n",
    "#✍✍✍\n",
    "PY_count"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 👼👼👼  辛苦了！  👼👼👼\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#终001 （勿改动，执行即可）回报答题分数\n",
    "import PandasCourse as PC\n",
    "score_details = PC.score_answers(locals(), _which_)\n",
    "score_details"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "339.111px"
   },
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
